% set null off set date ymd set cent on dateto =orequest.querystring("dateto") datefrom =orequest.querystring("datefrom") pcustomer =nvl(orequest.querystring("customerid"),[]) reportbase =orequest.querystring("reportbase") wheretext=[] thecustomername=[] REPTTITLE=[PROFIT BY CUSTOMER SUMMARY] REPTSECLINE=[] if isnull(dateto) or empty(ctod(dateto)) dateto=orequest.form("dateto") endif pdate2=ctod(dateto) if isnull(dateFROM) or empty(ctod(dateFROM)) dateto=orequest.form("dateFROM") endif pdate1=ctod(dateFROM) set date british wheretext=" AND X.accountid = Y.ACCOUNTID and (x.vtype=[Invoice] or x.vtype=[CreditMemo]) and x.itemid=z.itemid " ordertext=" order by y.name,y.accountid, x.date, x.transid " Do Case Case Empty(pdate1) And Empty(pdate2) * NEEDS NO CODE Case Empty(pdate1) And Not Empty(pdate2) wheretext=Alltrim(wheretext)+" And x.Date <= PDate2 " Case Not Empty(pdate1) And Empty(pdate2) wheretext=Alltrim(wheretext)+" And x.Date >= PDate1 " Case Not Empty(pdate1) And Not Empty(pdate2) wheretext=Alltrim(wheretext)+" And BETWEEN(x.Date,pdate1,pdate2) " Endcase If Not Empty(pcustomer) wheretext=Alltrim(wheretext)+" and x.Accountid=pCustomer " Endif if not empty(wheretext) wheretext=[where ]+subst(wheretext,5) endif set decimal to 4 tstr=[
| date | Voucher | NUM# | Details | QTY | SALE | COST | PROF | MKP% | |
|---|---|---|---|---|---|---|---|---|---|
| ]+allt(thisname)+[ (]+thisac+[) | |||||||||
| ]+iif(empty(date),[ ],transform(date))+[ | ] thislinestr=thislinestr+[]+iif(empty(vtype),[ ],transform(vtype))+[ | ] thislinestr=thislinestr+[]+iif(empty(transid),[ ],ALLT(transid))+[ | ] thislinestr=thislinestr+[]+itname+[ | ] thislinestr=thislinestr+[]+transform(thisqty)+[ | ] thislinestr=thislinestr+[]+transform(thissale)+[ | ] thislinestr=thislinestr+[]+transform(thiscost)+[ | ] thislinestr=thislinestr+[]+transform(thisprofit)+[ | ] thislinestr=thislinestr+[]+transform(profitpercentage)+[ | ] thislinestr=thislinestr+[|
| Sales | ]+allt(transform(sumsale))+[ | ] tstr=tstr+[Refunds | ]+allt(transform(sumrefunds))+[ | ] tstr=tstr+[Net Sales | ]+allt(transform(sumsale-sumrefunds))+[ | ||||
| Sale Profit | ]+allt(transform(totsaleprofit))+[ | ] tstr=tstr+[Refund Profit | ]+allt(transform(totalrefundprofit))+[ | ] tstr=tstr+[Net Profit | ]+allt(transform(totalnetproft))+[ | ||||
| Overall Markup% | ]+allt(transform(oprofitpercentage))+[ | ||||||||